import * as shoppingCartApi from '@/api/shoppingCart';

export default {
  namespaced: true,
  state() {
    return {
      cartList: [],
    };
  },
  mutations: {
    SET_CART_LIST(state, newValue) {
      state.cartList = newValue;
    },
  },
  actions: {
    async updateCartList({ commit }) {
      await shoppingCartApi.getCartList()
        .then((res) => {
          commit('SET_CART_LIST', res);
        })
        .catch(() => ({}));
    },
  },
};
